import request from "@/utils/request"

/**
 * 计算订单
 * @param data
 */
export function asyncCalcOrder(data) {
  return request.post('/order-pays/calculate-order', data)
}

/**
 * 提交订单
 * @param data
 */
export function submitOrder(data) {
  const MobileDetect = require('mobile-detect')
  const md = new MobileDetect(navigator.userAgent)
  return request.post('/order-pays/submit-order', {...data, phoneMode: md.mobile()})
}

/**
 * 计算虚拟订单
 * @param data
 */
export function calcVirtualOrder(data) {
  return request.post('/virtual-pays/calculate-order', data)
}

/**
 * 提交虚拟订单
 * @param data
 */
export function submitVirtualOrder(data) {
  return request.post('/virtual-pays/submit-order', data)
}

/**
 * 计算积分订单
 * @param data
 */
export function asyncCalcScoresOrder(data) {
  return request.post('/order-scores/calculate-order', data)
}

/**
 * 提交订单
 * @param data
 */
export function submitScoresOrder(data) {
  return request.post('/order-scores/submit-order', data)
}

/**
 * 微信支付
 */
export function goToWechatPay(id) {
  return request.get(`/order-pays/go-to-pay/${id}`)
}

/**
 * 微信支付
 */
export function goH5ToPay(id) {
  return request.get(`/order-pays/h5-to-pay/${id}`)
}

/**
 * 货到付款
 */
export function afterToPay(id) {
  return request.get(`/order-pays/after-to-pay/${id}`)
}

/**
 * 微信支付
 */
export function goToPayInMp(id) {
  return request.request({
    url: `/order-pays/go-to-pay-in-mp/${id}`
  })
}

// /**
//  * 支付宝支付
//  */
// export function goAliPay(id) {
//   return request.get(`/ali-pays/h5-to-pay/${id}`)
// }
export function mobileSmsRefresh() {
  return request.get(`/sms/refresh`)
}


/**
 * 钱包支付
 */
export function goToWalletPay(id) {
  return request.get(`/order-pays/wallet-to-pay/${id}`)
}

/**
 * 分页获取订单
 * @param params 请求参数
 */
export function getOrderPage(params: any) {
  return request.get('/orders/get-page', { params })
}

/**
 * 订单信息
 */
export function getOrderInfo(id) {
  return request.get(`/orders/get-by-id/${id}`)
}

/**
 * 物流信息
 */
export function getOrderExpress(expressNo) {
  return request.get(`/order/query-kdi?expressNo=${expressNo}`)
}

/**
 * 获取核销码
 */
export function getQrCode(id) {
  return request.get(`/orders/get-qr-code/${id}`)
}

/**
 * 确认收货
 */
export function confirmReceipt(id) {
  return request.put('/orders/receive-by-id',{
    id
  })
}

/**
 * 取消订单
 */
export function cancelOrderInfo(id) {
  return request.put(`/orders/cancel-by-id/${id}`)
}

/**
 * 删除订单
 */
export function delOrderInfo(id) {
  return request.get(`/orders/del-by-id/${id}`)
}


/**
 * 退单
 */
export function refundOrder(data) {
  return request.post('/orders/refund-by-id', data)
}

/**
 * 获取上次自提填写的信息
 */
export function getConnectUser() {
  return request.get('/orders/get-connect-user')
}

/**
 * 投诉
 */
export function postComplainAdd(data) {
  return request.post('/complain/add', data)
}






